//
//  VKStudyDaCard2Cell.m
//  V-Learn
//
//  Created by liubo on 2019/2/13.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKStudyDaCard2Cell.h"

@implementation VKStudyDaCard2Cell{
    UILabel *_titleLabel;
    UIImageView *_arrowImageV;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    VKStudyDaCard2Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"VKStudyDaCard2Cell"];
    if (cell == nil) {
        cell = [[VKStudyDaCard2Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"VKStudyDaCard2Cell"];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 点击cell的时候不要变色
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        
        // 布局子控件
        [self autoLayout];
    }
    return self;
}

-(void)setModel:(VKStudyDaCardModel *)model{
    _titleLabel.text = model.leftLabel;
    [_contentBtn setTitle:model.rightLabel forState:UIControlStateNormal];
}

- (void)autoLayout{
    
    UILabel *titleLabel = [[UILabel alloc]init];
    _titleLabel = titleLabel;
    [self.contentView addSubview:titleLabel];
    titleLabel.text = @"打卡规则";
    titleLabel.textColor = [UIColor cz_colorWithRed:62 green:62 blue:62];
    titleLabel.font = [UIFont systemFontOfSize:16];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    UIImageView *arrowImageV = [[UIImageView alloc]init];
    _arrowImageV = arrowImageV;
    arrowImageV.image = [UIImage imageNamed:@"left"];
    [self.contentView addSubview:arrowImageV];
    [arrowImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.mas_equalTo(-15);
    }];
    
    UIButton *contentBtn = [[UIButton alloc]init];
    [self.contentView addSubview:contentBtn];
    _contentBtn = contentBtn;
    //    contentLabel.text = @"小苹果";
    contentBtn.backgroundColor = [UIColor whiteColor];
    //    contentBtn.titleLabel.textAlignment = NSTextAlignmentRight;
    contentBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    contentBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    [contentBtn setTitleColor:[UIColor cz_colorWithRed:107 green:107 blue:107] forState:UIControlStateNormal];
    contentBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [contentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(arrowImageV.mas_left).offset(-10);
        make.centerY.mas_equalTo(self.contentView);
        make.width.equalTo(@83.8);
        make.height.equalTo(@30);
        
    }];
    
    UIView *lineView = [[UIView alloc]init];
    [self.contentView addSubview:lineView];
    lineView.backgroundColor = [UIColor cz_colorWithRed:244 green:244 blue:244];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@0);
        make.height.equalTo(@1);
        make.bottom.mas_equalTo(self.contentView);
    }];
}

@end
